package com.example.teaching_server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDate;

/**
 * 签到活动实体类 - 修正版（匹配数据库表结构）
 */
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = "id")
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "check_in_activities")
public class CheckInActivity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "title", nullable = false)  // 数据库列名是title
    @NotBlank(message = "活动标题不能为空")
    private String title;

    @Column(name = "start_date", nullable = false)
    @NotNull(message = "开始日期不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate startDate;

    @Column(name = "end_date", nullable = false)
    @NotNull(message = "结束日期不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate endDate;

    @Column(name = "is_checked", nullable = false)  // 数据库列名是is_checked
    @Builder.Default
    private Boolean isChecked = false;

    @Column(name = "total_days", nullable = false)  // 数据库列名是total_days
    @NotNull(message = "总天数不能为空")
    private Integer totalDays;

    @Column(name = "checked_days", nullable = false)  // 数据库列名是checked_days
    @Builder.Default
    private Integer checkedDays = 0;

    // 注意：数据库中check_in_activities表没有created_at和updated_at字段
    // 移除了这两个字段
}
